package middleware

import (
	"gitee.com/yangguoliang001/go-gin-vue3/config"
	"gitee.com/yangguoliang001/go-gin-vue3/pkg/file"
	"gitee.com/yangguoliang001/go-gin-vue3/pkg/response"
	"gitee.com/yangguoliang001/go-gin-vue3/util/code"
	"github.com/gin-gonic/gin"
)

func CheckInstall() gin.HandlerFunc {
	_, ok := file.IsExist(config.ProjectInstallMark)
	return func(c *gin.Context) {
		if !ok {
			//c.Redirect(http.StatusTemporaryRedirect, "/install")
			response.Fail(c, code.InitialError, code.Text(code.InitialError), gin.H{})
			c.Abort()
		} else {
			c.Next()
		}
	}
}
